//
//  WGQAttendanceRecordsCountTableViewCell.m
//  meiang_edu
//
//  Created by JUMIWGQ on 2018/9/28.
//  Copyright © 2018 com.meiang.meiang_edu. All rights reserved.
//

#import "WGQAttendanceRecordsCountTableViewCell.h"

@interface WGQAttendanceRecordsCountTableViewCell ()

@property (nonatomic,strong) UILabel * leftLabel;//左侧的文字label
@property (nonatomic,strong) UIView * colorView;//圆形的颜色标识图形
@property (nonatomic,strong) UILabel * rightLabel;//右侧的label
@end

@implementation WGQAttendanceRecordsCountTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self addSubViews];
    }
    return self;
}

- (void)addSubViews
{
    //带圆角的背景图
    UIView * backView = [[UIView alloc] init];
    backView.layer.masksToBounds = YES;
    backView.layer.cornerRadius = 7 * kScale;
    [self.contentView addSubview:backView];
    [backView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.top.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
    }];
    
    //左侧的klabel
    self.leftLabel = [[UILabel alloc] init];
    self.leftLabel.textAlignment = NSTextAlignmentLeft;
    self.leftLabel.textColor = FFColor(0x999999);
    self.leftLabel.font = [UIFont fontWithName:kMainFontFormat size:14 * kScale];
    [backView addSubview:self.leftLabel];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(backView.mas_left).offset(12 * kScale);
        make.centerY.equalTo(backView.mas_centerY);
    }];
    
    //圆形颜色
    self.colorView = [[UIView alloc] init];
    self.colorView.layer.masksToBounds = YES;
    self.colorView.layer.cornerRadius = 8 * kScale;
    [backView addSubview:self.colorView];
    [self.colorView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.width.and.height.mas_equalTo(16 * kScale);
        make.centerY.equalTo(backView.mas_centerY);
        make.left.equalTo(self.leftLabel.mas_right).offset(12 * kScale);
    }];
    
    self.rightLabel = [[UILabel alloc] init];
    self.rightLabel.textAlignment = NSTextAlignmentRight;
    self.rightLabel.textColor = FFColor(0x999999);
    self.rightLabel.font = [UIFont fontWithName:kMainFontFormat size:14 * kScale];
    [backView addSubview:self.rightLabel];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.right.equalTo(backView.mas_right).offset(-12 * kScale);
        make.centerY.equalTo(backView.mas_centerY);
    }];
}

- (void)setObject:(id)object
{
    if ([object isKindOfClass:[NSDictionary class]])
    {
        NSDictionary * dict = object;
        self.leftLabel.text = dict[@"title"];
        if ([self.leftLabel.text isEqualToString:@"正常出勤"])
        {
            self.colorView.backgroundColor = FFColor(0x3dd982);
        }
        if ([self.leftLabel.text isEqualToString:@"请假"])
        {
            self.colorView.backgroundColor = FFColor(0xf14d4d);
        }
        if ([self.leftLabel.text isEqualToString:@"增加"])
        {
            self.colorView.backgroundColor = FFColor(0xff9000);
        }
        
        self.rightLabel.text = [NSString stringWithFormat:@"%@次",dict[@"count"]];
    }
}

- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

@end
